package com.yjs.app.trade.web.controller.sys;


import java.io.IOException;
import java.sql.SQLException;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yjs.app.trade.service.service.sys.QuestionService;
import com.yjs.app.trade.web.controller.base.BaseController;
import com.yjs.app.trade.web.controller.base.util.Result;

import net.sf.json.JSONObject;

@Controller
@RequestMapping(value = "/app/sys/question")
public class QuestionController extends BaseController {

	@Autowired
	QuestionService questionService;

	/**
	 * 查询所有的常见问题
	 * @return
	 * @throws IOException 
	 * @throws SQLException 
	 */
	@RequestMapping(value="/findFAQPage",method=RequestMethod.GET)
	@ResponseBody
	public Object findFAQPage() throws SQLException, IOException{
		return Result.csuccess(questionService.findFAQPage());
	}
	
	/**
	 * 根据问题ID查询问题
	 * @param data
	 * @return
	 * @throws IOException 
	 * @throws SQLException 
	 */
	@RequestMapping(value="/getFAQById",method=RequestMethod.GET)
	@ResponseBody
	public Object getFAQById(String data) throws SQLException, IOException{
		JSONObject jsonObject = dpackData(data);
		String id = jsonObject.getString("faqId");
		Map<String, Object> map = questionService.getFAQById(id);
		return Result.csuccess(map);
	}
	
}
